/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dataanalysis.gui.dataviewer;

import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.table.TableModel;
import weka.core.Instances;

/**
 *
 * @author Administrator
 */
public class VariableTableView extends BaseTableView {

    private int m_numRows;

    public VariableTableView(int r, int c) {
        super(r, c);
        m_numRows = r;
        m_tableContent.getColumnModel().getColumn(2).setCellRenderer(new CellRenderer());
        m_tableContent.getColumnModel().getColumn(3).setCellRenderer(new CellRenderer());
    }

    @Override
    public void setInstances(Instances data) {
        if (data != null && data.classIndex() == -1) {
            data.setClassIndex(data.numAttributes() - 1);
        }
        VariableTableModel model = new VariableTableModel(m_numRows);
        model.setInstances(data);
        m_tableContent.setModel(model);
        super.setInstances(data);
    }

    @Override
    protected TableModel createTableModel(int r, int c) {
        return new VariableTableModel(r);
    }

    @Override
    protected void adjustLayout() {
        JComboBox combo = new JComboBox();
        combo.addItem("NOMINAL");
        combo.addItem("NUMERIC");
        combo.addItem("STRING");
        combo.addItem("DATE");
        combo.addItem("RELATIONAL");

//        JCheckBox check=new JCheckBox();

        m_tableContent.getColumnModel().getColumn(2).setCellRenderer(new CellRenderer());
        m_tableContent.getColumnModel().getColumn(3).setCellRenderer(new CellRenderer());
//        m_tableContent.getColumnModel().getColumn(0).setCellEditor(null);
        m_tableContent.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(combo));
//        m_tableContent.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(check));
//        m_tableContent.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(check));

    }

    @Override
    protected void setLayout() {
        this.setMargin(2, 2);
        this.setCellSize(120, 23);
    }
}
